<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: Session</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: Session</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Session<span class="signature">()</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="Session"><span class="type-signature"></span>new Session<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    封装对session的操作。DuerOS提过了多轮对话的能力，也能替Bot管理多轮对话，无须Bot自己维护session状态。
同时，也提供了Session存储，Bot还可以将对话的状态保存session中，自己处理多轮逻辑。
但是，存储在session中的数据，DuerOS是无法将其自动应用到下一轮的query解析中，对话状态的维护需要Bot自己完成
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line22">line 22</a>
    </li></ul></dd>
    

    

    

    
</dl>


















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    清空session的所有attributes
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line54">line 54</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="getData"><span class="type-signature"></span>getData<span class="signature">(field, def)</span><span class="type-signature"> &rarr; {string|Object}</span></h4>
    

    



<div class="description">
    从session中获取一个属性的值
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>field</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性名称</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>def</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">默认值</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line81">line 81</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>
|

<span class="param-type">Object</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>this.getData('status');
this.getData('status', '1');</code></pre>



        
            

    

    
    <h4 class="name" id="setData"><span class="type-signature"></span>setData<span class="signature">(field, value, def)</span><span class="type-signature"> &rarr; {null}</span></h4>
    

    



<div class="description">
    将一个值存储到session中
注意：
     value必须是字符串
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>field</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性名称</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性值</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>def</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">默认值</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line114">line 114</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">null</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>this.setData('status', '1');
this.setData('status', '1', '8');</code></pre>



        
            

    

    
    <h4 class="name" id="toResponse"><span class="type-signature"></span>toResponse<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    将session输出response的格式
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line63">line 63</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
    

    

    
</article>

</section>







<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>Session<span class="signature">(data)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="Session"><span class="type-signature"></span>new Session<span class="signature">(data)</span><span class="type-signature"></span></h4>
    

    











    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">请求bot的session数据</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line34">line 34</a>
    </li></ul></dd>
    

    

    

    
</dl>


















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    清空session的所有attributes
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line54">line 54</a>
    </li></ul></dd>
    

    

    

    
</dl>


















        
            

    

    
    <h4 class="name" id="getData"><span class="type-signature"></span>getData<span class="signature">(field, def)</span><span class="type-signature"> &rarr; {string|Object}</span></h4>
    

    



<div class="description">
    从session中获取一个属性的值
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>field</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性名称</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>def</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">默认值</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line81">line 81</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>
|

<span class="param-type">Object</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>this.getData('status');
this.getData('status', '1');</code></pre>



        
            

    

    
    <h4 class="name" id="setData"><span class="type-signature"></span>setData<span class="signature">(field, value, def)</span><span class="type-signature"> &rarr; {null}</span></h4>
    

    



<div class="description">
    将一个值存储到session中
注意：
     value必须是字符串
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>field</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性名称</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                </td>
            

            <td class="description last">属性值</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>def</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            
                <td class="default">
                
                    null
                
                </td>
            

            <td class="description last">默认值</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line114">line 114</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">null</span>


    </dd>
</dl>

    




    <h5>Example</h5>
    
    <pre class="prettyprint"><code>this.setData('status', '1');
this.setData('status', '1', '8');</code></pre>



        
            

    

    
    <h4 class="name" id="toResponse"><span class="type-signature"></span>toResponse<span class="signature">()</span><span class="type-signature"> &rarr; {Object}</span></h4>
    

    



<div class="description">
    将session输出response的格式
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="Session.js.html">Session.js</a>, <a href="Session.js.html#line63">line 63</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    





        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BaseCard.html">BaseCard</a></li><li><a href="BaseDirective.html">BaseDirective</a></li><li><a href="Bot.html">Bot</a></li><li><a href="card_BaseCard.js.html">card/BaseCard.js</a></li><li><a href="Certificate.html">Certificate</a></li><li><a href="directive_BaseDirective.js.html">directive/BaseDirective.js</a></li><li><a href="ImageCard.html">ImageCard</a></li><li><a href="ListCard.html">ListCard</a></li><li><a href="ListCardItem.html">ListCardItem</a></li><li><a href="Nlu.html">Nlu</a></li><li><a href="Play.html">Play</a></li><li><a href="Request.html">Request</a></li><li><a href="Response.html">Response</a></li><li><a href="Session.html">Session</a></li><li><a href="StandardCard.html">StandardCard</a></li><li><a href="Stop.html">Stop</a></li><li><a href="TextCard.html">TextCard</a></li></ul><h3>Namespaces</h3><ul><li><a href="Bot.Card.html">Card</a></li><li><a href="Bot.Directive.html">Directive</a></li><li><a href="Bot.Directive.AudioPlayer.html">AudioPlayer</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Nov 04 2017 11:19:40 GMT+0800 (CST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>